from typing import List
class Solution:
    def permute(self, nums: List[int]) -> List[List[int]]:
        if len(nums) <= 1:
            return [nums]

        ans=[]
        for i,num in enumerate(nums):
            #i是索引，num是值
            n=nums[:i]+nums[i+1:]
            for j in self.permute(n):
                ans.append([num]+j)

        return ans


#全排列